package com.cskaoyan.controller;

import com.cskaoyan.bean.User;
import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author stone
 * @date 2022/05/04 11:40
 */
@RestController
public class HelloController {

    @Value("${user.username}")
    String name;

    @Autowired
    UserService userService;

    @RequestMapping("hello")
    public String hello() {
        return "hello " + name;
    }

    @RequestMapping("user/{id}")
    public User user(@PathVariable("id") Integer id) {
        return userService.query(id);
    }
}
